#include <stdio.h>
#include <stdlib.h>
int gettmp();
main()
{
int a=1;
int b=0;
int temp=0;
while (a!=0)
{
	sleep(2);
	system("clear");
	temp=gettmp();
	if(temp>61){
	printf("Now CPU temperature is %d! Check Your Fan!!!\n",temp);
	if ((b>=3)||(temp>=63)){
				system("mplayer /usr/local/share/sound/chord.wav 1>/dev/null 2>/dev/null");
			}
	b+=1;
 	}
	else{printf("CPU temperature: %d.\n",temp);
		b=0;
		}
}

return 0;
}

int gettmp()
{
FILE *fp;
int tmpr;
if((fp=fopen("/proc/acpi/thermal_zone/THRM/temperature","r"))==NULL)
	{
		printf("An Critical Error Occured! Check Your ACPI system!\n");
		exit(1);
	}
fscanf(fp,"temperature:             %d C",&tmpr);
fclose(fp);
return tmpr;
}
